﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace GPSTracker.Helper
{
    public class CommonFx
    {
        private static SqlConnection sqlCon;

        public static string GetSqlConStr()
        {
            return ConfigurationManager.ConnectionStrings["MainConn"].ConnectionString;
        }

        public static SqlConnection GetSqlCon()
        {
            if (sqlCon == null)
            {
                sqlCon = new SqlConnection(CommonFx.GetSqlConStr());
                sqlCon.Open();
            }
            else
            {
                if (sqlCon.State == ConnectionState.Closed)
                {
                    sqlCon.Open();
                }
            }
            return sqlCon;
        }
    }
}
